﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Manager_AddTeacher : System.Web.UI.Page
{
    CommonClass ccobj = new CommonClass();
    DBClass dbobj = new DBClass();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            bindDepart();
    }
    protected void bindDepart()
    {
        string strsql = "select * from Department";
        DataTable dstable = dbobj.GetDataSet(strsql, "tabdepartment");
        DropDownList1.DataSource = dstable.DefaultView;
        DropDownList1.DataTextField = dstable.Columns[1].ToString();
        DropDownList1.DataValueField = dstable.Columns[0].ToString();
        DropDownList1.DataBind();
        DropDownList1.Items.Insert(0, "请选择");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string strsql = "insert into Teacher(TeacherID,TeacherName,PassWord,Sex,Email,ClassID) values('" + TextBox1.Text.Trim() + "','" + TextBox2.Text.Trim() + "','" + TextBox1.Text.Trim() + "','" + RadioButtonList1.SelectedItem.Value.ToString() + "','" + TextBox3.Text.Trim() + "','" + DropDownList2.SelectedValue.ToString() + "')";
        dbobj.ExecNonQuery(strsql);
        Response.Write(ccobj.MessageBox("添加辅导员成功！"));
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        TextBox1.Text = "";
        TextBox2.Text = "";
        TextBox3.Text = "";
        RadioButtonList1.SelectedIndex = -1;
        DropDownList1.SelectedIndex = 0;
        DropDownList2.SelectedIndex = -1;
    }
    protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}